
import requests
class Employee:
    def __init__(self):
        self.url = "http://127.0.0.1:8080"
        self.headers = {"Content-Type": "application/json"}
        self.headers_token = {"Content-Type": "application/json", "token": "eyJhbGciOiJIUzI1NiJ9.eyJlbXBJZCI6MSwiZXhwIjoxNzUzNzg2OTM3fQ.uwVPFrbB3tFxr5_gcNJOqNbjVVhn090wACDs57ksvI0"}

    # url拼接
    def get_url(self, URL):
        return self.url+URL
    def login(self, URL,login_data):
        return requests.post(self.get_url(URL), data=login_data, headers=self.headers)

    # 新增员工
    def add_employee(self,URL, add_data, headers):
        return requests.post(self.get_url(URL), json=add_data, headers=headers)

    # 查询员工信息
    def query_employee(self, URL):
        return requests.get(self.get_url(URL),headers=self.headers_token)

    # 编辑员工信息
    def edit_employee(self, URL, edit_data):
        return requests.put(self.get_url(URL), json=edit_data, headers=self.headers_token)
    # 员工分页查询
    def query_employee_paging(self, URL, query_data):
        return requests.get(self.get_url(URL), params=query_data, headers=self.headers_token)

    # 启用、禁用员工账号
    def enable_employee(self, URL, enable_data):
        return requests.post(self.get_url(URL), params=enable_data, headers=self.headers_token)